<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>对整个body进行监听</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <style>

        h4{
            padding-top: 50px;
        }
       
    </style>
</head>
<!--滚动监听区域-->
<body data-spy="scroll" data-target="#selector" style="height:2000px">
<!--菜单容器-->
<nav class=" navbar navbar-default navbar-fixed-top" id="selector">
    <ul class="nav navbar-nav ">
        <li class="active"><a href="#name1">@fat</a></li>
        <li><a href="#name2">@mdo</a></li>
        <li><a href="#name3">one</a></li>
        <li><a href="#name4">two</a></li>

    </ul>
</nav>

<h4 id="name1">@fat</h4>

<p>
    Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi
    before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim
    keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon
    irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you
    probably haven't heard of them et cardigan trust fund culpa biodiesel wes
    anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh
    artisan ullamco consequat.
</p>
<h4 id="name2">@mdo</h4>

<p>
    Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard.
    Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi,
    ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis
    non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic
    exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar
    deserunt.
</p>
<h4 id="name3"> one</h4>

<p>
    Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea.
    Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore
    single-origin coffee in magna veniam. High life id vinyl, echo park consequat
    quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi
    DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny
    pack iphone.
</p>
<h4 id="name4"> two</h4>

<p>
    In incididunt echo park, officia deserunt mcsweeney's proident master cleanse
    thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1
    biodiesel laborum craft beer. Single-origin coffee wayfarers irure four
    loko, cupidatat terry richardson master cleanse. Assumenda you probably
    haven't heard of them art party fanny pack, tattooed nulla cardigan tempor
    ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable.
    Elit wolf voluptate, lo-fi ea portland before they sold out four loko.
    Locavore enim nostrud mlkshk brooklyn nesciunt.
</p>
<br/>
<br/>
<br/>
<br/>
<br/>


<script src="../js/jquery-1.12.4.js"></script>
<script src='../js/bootstrap.min.js'></script>
<script>
//    $('body').scrollspy({target:"#selector"});




//滚动监听属性

/* $('body').scrollspy({
    "offset":100
 });*/







//滚动监听事件
//当滚动监听插件将某个元素设置为active样式的时候，触发此事件

//$('body').on('activate.bs.scrollspy', function () {
//  // do something…
//  alert(1);
//})

</script>
</body>
</html>